<script setup lang="ts">
import type {NuxtError} from "#app";

const props=defineProps({
  error: Object as () => NuxtError
})
const handleError = () => {
  bottomBarStore().index=0
  clearError({redirect: '/home'})
}
onMounted(function (): void {
  if(props.error?.statusCode===401){
    navigateTo('/login')
  }
})
</script>

<template>
  <div class="container">
    <h2>{{ error?.statusCode }}</h2>
    <pre>
  {{ error?.message }}
      {{error?.cause}}
  </pre>
    <van-button type="primary" @click="handleError">回到首页</van-button>
  </div>

</template>

<style scoped>
.container{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 20px;
}
</style>